/*
Copyright (c) [2019年5月1日] [吴超]
[MBT_Studio] is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
		 http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
*/
#pragma once


#include <矩阵.h>
#include <几何数据.h>

#include "矩阵计算.h"
//#include "A_CUDA数学Core/vec3.h"
//#include "A_CUDA数学Core/maths.h"




inline void f_vec3右手转左手坐标系(Vec3* vert, uint32 num) {
	C_Mat44 转换矩阵 = f_Identity();
	
	C_Mat44 旋转矩阵 = RotationMatrix(float32(M_角度转弧度(90)), Vec3(1.0, 0.0, 0.0));
	C_Mat44 缩放矩阵 = ScaleMatrix(Vec3(1.0, 1.0, -1.0));

	转换矩阵 *= 旋转矩阵;
	转换矩阵 *= 缩放矩阵;

	for (uint32 i = 0; i < num; ++i) {
		vert[i] = 转换矩阵 * vert[i];
	}

}





CUDA_CALLABLE Inline std::vector<vec3> vec_矩阵变换(const std::vector<vec3>& oldPos, const C_Mat44 mat) {
	
	uint32 num = oldPos.size();
	auto* vert = oldPos.data();

	std::vector<vec3> r(num);
	auto* r_p = r.data();
	for (uint32 i = 0; i < num; ++i) {
		r_p[i] = mat * vert[i];
	}
	return r;
}


CUDA_CALLABLE Inline std::vector<vec3> vec_矩阵变换(const std::vector<vec4>& oldPos, const C_Mat44 mat) {

	uint32 num = oldPos.size();
	auto* vert = oldPos.data();

	std::vector<vec3> r(num);
	auto* r_p = r.data();
	for (uint32 i = 0; i < num; ++i) {
		r_p[i] = mat * vec3{ vert[i].x, vert[i].y, vert[i].z };
	}
	return r;
}


